﻿using System;
using System.Collections.Generic;
using System.IO;
using CSJ2K.Util.IO;

namespace CSJ2K.Jpc.Segments
{
    /// <summary>Start of data (SOD)</summary>
    /// <comment>
    /// Function: Indicates the beginning of bit stream data for the current tile-
    ///      part. The SOD also indicates the end of a tile-part header. 
    /// Usage: Every tile-part header. Shall be the last marker in a tile-part header.
    ///      Bit-stream data between an SOD and the next SOT or EOC (end of image) 
    ///      shall be a multiple of 8 bits – the codestream is padded with bits, as 
    ///      needed. There shall be at least one SOD in a codestream. There shall be 
    ///      one SOD per tile-part. 
    /// Length: Fixed. 
    /// </comment>
    public class SOD : Segment
    {
        public SOD(Stream source)
            : this(source, (Markers)StreamUtil.ReadBUInt16(source)) { }
        public SOD(Stream source, Markers marker)
            : base(source, marker, false)
        {
            if (marker != Markers.SOD) throw (new ApplicationException("Attempting to create segment of the wrong type."));

        }
    }
}
